/*
 * WindowHelper
 *
 *  Created on: Fevereiro 4
 *
 */

#ifndef Helpers_H_
#define Helpers_H_

#include "SDL/SDL.h"

#include "core/GameConteiner.h"
#include "util/EatsVars.h"
#include <string>
#include <sstream>
#include <vector>

using namespace eats_core;
using namespace eats_vars;

namespace eats_helpers {

class CoordinatesHelper {

public:

	static int inline bottonLeftWidth() {
		return 0;
	}

	static int inline bottonRightWidth(int offset = 0) {
		return GameConteiner::getInstance()->getGameManager()->getWidthSize()
				- offset;
	}

	static int inline bottonLeftHeight(int offset = 0) {
		return GameConteiner::getInstance()->getGameManager()->getHeighSize()
				- offset;
	}

	static Point inline getAPoint(int _x, int _y) {
		Point p;
		p.x = _x;
		p.y = _y;
		return p;

	}

	static bool inline isOnRange(Point * enemy, Point * center, int range) {
		if ((((enemy->x - center->x) * (enemy->x - center->x))
				+ ((enemy->y - center->y) * (enemy->y - center->y)))
				< (range * range)) {
			return true;
		} else {
			return false;
		}
	}

	static bool inline isOnRect(Point origin, int width, int height,
			Point click) {
		if (click.x > origin.x && click.y > origin.y) {
			if (click.x < (width + origin.x) && click.y < (height + origin.y)) {
				return true;
			}
			return false;
		}
		return false;
	}

};

class ResourceHelper {

public:
	static std::string getNemliniumPath() {
		return "/opt/attacks/resources/nemlinium";
	}

	static int getNemliniumTileSize(){
		return 10;
	}

};

class PathHelper {

public:

	static std::string resourceResolution(bool forceRelook = false) {

		if (!strcmp(resourceResolutionStr.c_str(), "") || forceRelook) {
			resourceResolutionStr = "";
			std::stringstream width, height;
			width
					<< GameConteiner::getInstance()->getGameManager()->getWidthSize();
			height
					<< GameConteiner::getInstance()->getGameManager()->getHeighSize();
			resourceResolutionStr = resourceResolutionStr.append("__").append(
					width.str()).append("_").append(height.str());
		}

		return resourceResolutionStr;
	}

private:

	static std::string resourceResolutionStr;

};

class StringHelper {

public:

	template<class T>
	static std::string toString(const T& t) {
		std::ostringstream stream;
		stream << t;
		return stream.str();
	}

	template<class T>
	static T fromString(const std::string& s) {
		std::istringstream stream(s);
		T t;
		stream >> t;
		return t;
	}

};

}

#endif /* WindowHelper_H_ */
